<?php
if (isset($_COOKIE['c_usrname_adm']) && isset($_COOKIE['c_pwd_adm'])) {
    if ($_COOKIE['c_usrname_adm'] == "" && $_COOKIE['c_pwd_adm'] == "") {
        redirect('Admin/login');
    }
} else {
    redirect('Admin/login');
}
?>
<!DOCTYPE html>
<html>
<head>
    <title><?php echo $title; ?> | Travelina</title>
    <link href="<?php echo base_url() ?>/FontAwesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo base_url() ?>/Bootstrap/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="<?php echo base_url() ?>/Css/map.css" type="text/css" />
    <link href="<?php echo base_url() ?>/Css/admin.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo base_url() ?>/Fonts/Font_Importer.css" rel="stylesheet" type="text/css"/>
    <script src="<?php echo base_url() ?>/Bootstrap/jquery.js" type="text/javascript"></script>
    <script src="<?php echo base_url() ?>/Bootstrap/bootstrap.min.js" type="text/javascript"></script>

    <!-- Google Map Needs -->
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&region=IT"></script> 
    <script type="text/javascript" src="<?php echo base_url() ?>Js/getlocation.js"></script>
</head>
<body>
    <nav id="top-nav">
        <div class="col-sm-6">
            <h1 id="title">Admin Dashboard</h1>
        </div>
        <div class="col-sm-6">
            <small>
                <a data-toggle="modal" href="#EditProfile" class="btn btn-sm btn-primary pull-right"> Edit Profile</a>
            </small>

            
            <div class="modal fade" id="EditProfile" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                  <div class="modal-content">
                    <div class="modal-header">
                      <h4 class="modal-title"><i class="fa fa-pencil"></i><span>EDIT PROFILE</span></h4>
                  </div>
                  <form action="<?php echo site_url("Admin/proses_update_admin/$_COOKIE[c_id_adm]") ?>" method="POST">
                      <div class="modal-body">
                          <label>Username</label>
                          <?php $uname = $_COOKIE['c_usrname_adm']; ?>
                          <input class="form-control" type="text" name="username_adm" value="<?php echo $uname; ?>"/>
                          <label>Password</label>
                          <input class="form-control" type="password" name="password_adm" />
                          <label>Re-type Password</label>
                          <input class="form-control" type="password" name="re_password_adm"/>
                      </div>
                      <div class="modal-footer">
                          <input type="submit" class="btn btn-sm btn-primary" value="Update Profile" />
                          <button type="button" class="btn btn-sm btn-warning"  data-dismiss="modal" aria-hidden="true">Cancel</button>
                      </div>
                  </form>
              </div>
          </div>
      </div>
  </div>
</nav>

<div id="content-container" class="col-md-12">
    <div id="sidebar-menu" class="col-md-2">
        <ul>
            <li><a href="<?php echo site_url('Admin/') ?>"><i class="fa fa-fw fa-dashboard"></i> Dashboard</a></li>
            <li><a href="<?php echo site_url('Admin/user') ?>"><i class="fa fa-fw fa-users"></i> Users</a> &nbsp;<span class="badge"><?php echo count($user) ?></span></li>
            <li><a href="<?php echo site_url('Admin/post_page') ?>"><i class="fa fa-fw fa-file"></i> Posts</a> &nbsp;<span class="badge"><?php echo count($post) ?></span></li>
            <li><a href="<?php echo site_url('Admin/category') ?>"><i class="fa fa-fw fa-tags"></i> Categories</a> &nbsp;<span class="badge"><?php echo count($category) ?></span></li>
            <li><a href="<?php echo site_url('Admin/location') ?>"><i class="fa fa-fw fa-map-marker"></i> Locations</a> &nbsp<span class="badge"><?php echo count($location) ?></span></li>
            <li><a href="<?php echo site_url('Admin/logout'); ?>"><i class="fa fa-power-off fa-user"></i> Logout</a></li>
        </ul>
    </div>
    <div id="content" class="col-md-10">

        <h2 class="title-tab"><?php echo $title ?></h2>
        <?php if($this->session->flashdata('notif_sts') != ""): ?>
            <?php if($this->session->flashdata('notif_sts') == "1"): ?>
                <div class="alert alert-success">
                    <i class="fa fa-check-circle fa-2x"></i><br/><?php echo $this->session->flashdata('notif'); ?>
                    <br/>
                    <small>You must logout to save new configuration data. Yes, <a href="<?php echo site_url('Admin/logout') ?>">Log me out now</a></small>
                </div>
            <?php elseif($this->session->flashdata('notif_sts') == "0"): ?>
                <div class="alert alert-danger">
                    <i class="fa fa-exclamation-triangle fa-2x"></i><br/><?php echo $this->session->flashdata('notif'); ?>
                </div>
            <?php endif; ?>
        <?php endif; ?>
        <?php $this->load->view("admin/includes/i_$page") ?>
    </div>
</div>
</body>
</html>